home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: MegaDisc / MegaDisc 07 (1988)(MegaDisc Digital Publishing)(AU)[WB].zip / MegaDisc 07 (1988)(MegaDisc Digital Publishing)(AU)[WB].adf / BASIC_TUTE / Basic_Tute < prev    next >
Text File  |  2000-04-10  |  11KB  |  282 lines

  1.          
  2.  
  3.                 AMIGABASIC TUTORIAL PARTS 1-3
  4.  
  5.                                         By Jonathan Potter
  6.  
  7.  [ED NOTE: This is the first installment in a series of Basic tutorials
  8.            by Jonathan.]
  9.  
  10.  
  11.  
  12. INTRODUCTION
  13.  
  14.    This is a tutorial for AmigaBASIC,  probably the best BASIC available
  15. for any computer. While AmigaBASIC has its disadvantages, its wide range
  16. of commands, which give control over most of the Amiga's functions, and
  17. BASIC's traditional simplicity, as far as programming goes, heavily
  18. outweigh them. Commodore, however have provided their customers with a
  19. totally inadequate manual. This tutorial does not try to replace a manual,
  20. but I hope it will clarify a few points, especially for beginners to
  21. programming.
  22.    
  23.  
  24. STARTING IT UP
  25.  
  26.    Probably the easiest way to start up AmigaBASIC is from the WorkBench,
  27. however this is not the most efficient. WorkBench takes about 100K of
  28. memory, memory which many serious BASIC programs will need. For using
  29. AmigaBASIC, I have created an auto-booting disk which contains AmigaBASIC,
  30. the DEVICES and LIBRARIES necessary to utilise the parallel and serial
  31. ports, and the speech, and a directory for the actual programs. When the
  32. disk is created, there is about 45% free for BASIC files.
  33.  
  34. ***********************************************************************
  35.  
  36.    These instructions assume you have used the CLI before, BUT IF YOU
  37. HAVEN'T, DON'T WORRY. Just type every thing as shown, and all should be
  38. well. They also assume you have only one drive.
  39.  
  40. ***********************************************************************
  41.  
  42.    Insert your WorkBench disk at the prompt (the picture), and when the
  43. screen changes from white to whatever background colour you use, break into
  44. the CLI with a few CTRL-Ds. [ie, keep your CTRL and D keys pressed down as
  45. Workbench is booting up.]
  46.    The first thing to do is to create a RAMDISK containing a few, vital
  47. commands.
  48.  
  49.    MAKEDIR RAM:C
  50.    COPY C/COPY RAM:C
  51.    ASSIGN C: RAM:C
  52.    COPY C/CD RAM:C
  53.    COPY C/MAKEDIR RAM:C
  54.    COPY C/DELETE RAM:C
  55.    COPY C/FORMAT RAM:C
  56.    COPY C/INSTALL RAM:C
  57.    COPY C/LIST RAM:C
  58.    COPY C/INFO RAM:C
  59.  
  60.    Remove your WorkBench disk, and insert a blank disk, with the write
  61. protect tab towards the bottom of the disk [ie, Write-enabled, you can't
  62. see through the tab hole]. Then type:
  63.  
  64.    FORMAT DRIVE DF0: NAME AmigaBASIC
  65.    INSTALL DF0:
  66.    CD DF0:
  67.    MAKEDIR DEVS
  68.    MAKEDIR LIBS
  69.    MAKEDIR L
  70.    MAKEDIR PROGS
  71.  
  72.    Remove this disk, and insert WorkBench (referred to as WB from here on).
  73. Type:
  74.  
  75.    MAKEDIR RAM:DEVS
  76.    COPY DF0:DEVS RAM:DEVS ALL
  77.  
  78.    Reinsert your new AmigaBASIC disk (referred to as AB from here on).
  79. Type:
  80.  
  81.    COPY RAM:DEVS DF0:DEVS ALL
  82.    DELETE RAM:DEVS ALL
  83.  
  84.    Insert WB, and type:
  85.  
  86.    MAKEDIR RAM:LIBS
  87.    COPY DF0:LIBS RAM:LIBS ALL
  88.  
  89.    Insert AB, and type:
  90.  
  91.    COPY RAM:LIBS DF0:DEVS ALL
  92.    DELETE RAM:LIBS ALL
  93.  
  94.    Insert WB, and type:
  95.  
  96.    MAKEDIR RAM:L
  97.    COPY DF0:L RAM:L ALL
  98.  
  99.    Insert AB, and type:
  100.  
  101.    COPY RAM:L DF0:L ALL
  102.    DELETE RAM:L ALL
  103.  
  104.    Then insert the Extras disk (1.2 is better), and type:
  105.  
  106.    COPY DF0:AMIGABASIC RAM:
  107.  
  108.    Insert AB, and type:
  109.  
  110.    COPY RAM:AMIGABASIC DF0:
  111.    DELETE RAM:AMIGABASIC
  112.  
  113.    You can then type LIST, and you should see something like this:
  114.  
  115.    DEVS
  116.    LIBS
  117.    L
  118.    PROGS
  119.    AMIGABASIC
  120.  
  121.    Type INFO to see how much room is free on your NEW AUTOBOOTING AmigaBASIC
  122. disk!
  123.  
  124.    If you only ever use one type of printer, you can type:
  125.  
  126.    CD DEVS/PRINTERS
  127.    LIST
  128.  
  129.    and DELETE the printers you do not want. Be sure to type in the names
  130. exactly as shown. e.g DELETE CBM_MPS1000
  131.  
  132.    You can then do a CTRL-A-A to reset, and you should see a CLI screen come
  133. up, with the 1>  prompt. Type in AMIGABASIC and press RETURN, and after a
  134. while the AmigaBASIC screen should come up. You can then program to your
  135. heart's content (see the next section for some ideas on how to do that!),
  136. and when you save a program you should type SAVE "PROGS/progname". This will
  137. save the program to the PROGS directory, and will keep your disk nice and
  138. tidy. If you plan to be doing a lot of saving and loading, you could type
  139. CHDIR "PROGS" and then you can omit the PROGS/ prefix to the file name.
  140.  
  141.  
  142.  
  143.  
  144. THE `BASICS' OF PROGRAMMING
  145.  
  146.    Programming in BASIC on the Amiga is as simple as on any other machine,
  147. the only difference being the commands, and the editor you type into.
  148.    The editor (LIST Window) defaults as half a screen wide, and the full
  149. screen high. For my purposes that size suits me fine, but you may want to
  150. change it to cover the full screen. When AmigaBASIC first loads up, the
  151. editor window is the current window - to make the output window the current
  152. one, just click in it, and vice versa. While you can't move around in the
  153. output window (with the cursor keys at least) you can in the editor, and
  154. certain key combinations do different things.
  155.    The CURSOR KEYS by themselves will move the cursor one space in that
  156. direction. Holding down the SHIFT with a cursor key will move one page in
  157. that direction, and holding down ALT will move to the top or bottom of the
  158. program (up and down cursor keys), or to the start or end of the current
  159. line (left and right cursor keys).
  160.    Editing is simple too... you can Cut, Paste and Copy sections of the
  161. program, with the only limit to size being the amount of memory. To mark
  162. an area you hold down the left hand button on a particular line, and while
  163. holding it down, move the mouse up or down, depending on which direction
  164. you want to go. When the area has been marked, release the button, and you
  165. can then CUT (delete) the area with Left AMIGA-X, COPY the area with Left
  166. AMIGA-C, or PASTE a copied area with Left AMIGA-P. Note that to paste you
  167. do not have to mark an area - the lines will be inserted from the current
  168. cursor position downwards.
  169.  
  170. WHAT'S THIS ALL ABOUT?
  171.  
  172.    I said before that this was not to replace the manual (manual? what
  173. manual!) All it is is a simple tutorial on some of the finer points of
  174. AmigaBASIC. So I'm not going to go on and show you how to print hello, ask
  175. for your name, etc.. I'll assume you have used BASIC before, and just talk
  176. about some of the better features.
  177.    So let's start with everyone's favorite...
  178.  
  179. GRAPHICS
  180.  
  181.    AmigaBASIC supports all of the semi-standard BASIC graphics commands,
  182. such as CIRCLE, LINE, PAINT, PSET, as well as a few of its own.
  183.  
  184.    SCREEN and WINDOW
  185.  
  186.       These can be classified as graphics commands, because they are
  187. reasonably essential for graphics in BASIC.
  188.       SCREEN is used to define the parameters of a new screen - the width,
  189. height, depth (number of colours) and mode are all defined by SCREEN.
  190.       The FORMAT is SCREEN screen-id, width, height, depth, mode
  191.       The SCREEN-ID is a number from 1 to 4. Screen -1 is the WorkBench
  192. screen.
  193.       WIDTH is the width of the screen, in pixels, and can be any value
  194. from 1 to 640. WorkBench screen width is 640.
  195.       HEIGHT is the height of the screen, in pixels, and can be any value
  196. from 1 to 400. WorkBench screen height is 200.
  197.       DEPTH is the number of colours the screen can support. It is given
  198. as a number which is a power of 2. Therefore, a depth of 1 allows 2 colours
  199. (2^1), a depth of 5 allows 32 (2^5). The default WorkBench screen depth is
  200. 2 (4 colours).
  201.       MODE specifies which type of screen is to be used.
  202.  
  203.       MODE     SCREEN PRODUCED
  204.  
  205.       1        Low Resolution (320X200), non interlaced.
  206.       2        High Resolution (640X200), non interlaced.
  207.       3        Low Resolution (320X400), interlaced.
  208.       4        High Resolution (640X400), interlaced.
  209.  
  210.       WorkBench default is mode 2.
  211.  
  212.       Examples.
  213.  
  214.       SCREEN 1,640,200,2,2 - this will produce a WorkBench type screen.
  215.       SCREEN 3,640,400,5,4 - the highest resolution, most number of colours
  216.                              possible in BASIC.
  217.       SCREEN 2,320,200,1,1 - the lowest resolution, least number of colours
  218.                              possible in BASIC.
  219.  
  220.       A new screen takes about 30K for a lo-res screen (320X200 mode 1), 40K
  221. for a med-res screen (640X200 mode 2) and about 55K for a high-res screen
  222. (640X400 mode 4). This memory is taken from the Stack (more about that
  223. later).
  224.  
  225.  
  226.       AMIGABASIC TUTORIAL PART 3
  227.  
  228.        WINDOW is used to define the parameters of a new window.
  229.        It has one obligatory parameter and 4 optional, in the form:
  230.        WINDOW <window-id>,[<title>],[<(x1,y1)-(x2,y2)>],[<type>],
  231.               [<screen-id>]
  232.  
  233.        The WINDOW-ID is a number greater than 0. The BASIC work screen is
  234.        1. This is the obligatory parameter.
  235.        The TITLE is the window title.
  236.        (x1,y1)-(x2,y2) are the co-ordinates of the top left and bottom
  237.        right corners of the window. The default is for a full screen.
  238.        TYPE is a value from 0 to 31. The following table gives
  239.        the values and their function. To combine two or more functions,
  240.        simply add their values.
  241.  
  242.        VALUE   FUNCTION
  243.  
  244.        1       Gives the window a sizing gadget, enabling its
  245.                size to be changed.
  246.        2       Enables the window to be moved around by the
  247.                title (drag) bar.
  248.        4       Gives the window depth gadgets, enabling it to be
  249.                moved behind and infront of other windows.
  250.        8       Gives the window a close gadget, enabling it to
  251.                be closed.
  252.        16      Makes the contents of the window reappear after
  253.                it has been covered by another window. This
  254.                takes memory from the stack.
  255.  
  256.        SCREEN-ID is the screen which the window is to appear in.
  257.        The default is -1, the WorkBench screen.
  258.  
  259. Examples:
  260.  
  261.         WINDOW 2,"Hi There!",(0,0)-(100,100),31,1
  262.         WINDOW 18,,,16
  263.         WINDOW 1,"HELLO!",,31
  264.         WINDOW 3,,,0
  265.  
  266.        In the above examples, the first command creates a window 100X100
  267.        pixels, with all the gadgets visible, on screen 1. The second
  268.        creates a full screen window, on the WorkBench screen. The third
  269.        replaces the BASIC work window, and the fourth creates a borderless
  270.        window, on the default WorkBench screen (-1).
  271.             Note that if you wish to leave some parameters out, but include
  272.        following parameters, you must put a comma in place of the missing
  273.        parameters (e.g WINDOW 3,,(0,0)-(200,100),,2), but no commas are
  274.        necessary if no parameters follow the missing ones. This is true for
  275.        all AmigaBASIC commands.
  276.  
  277.  
  278.  
  279. ^^^^^^^^^^^^^^^^^^^^^^^^ END OF BASIC_TUTE ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  280. ^^^^^^^^^^^^^^^^^^ SEE NEXT ISSUE OF MEGADISC FOR MORE ^^^^^^^^^^^^^^^^^^^
  281.  
  282.